home *** CD-ROM | disk | FTP | other *** search
/ Info-Mac 4 / Info_Mac IV CD-ROM (Pacific HiTech Inc.)(August 1994).iso / Development / General / MWC & CodeResources / WDEF.c < prev    next >
C/C++ Source or Header  |  1994-01-13  |  3KB  |  96 lines

  1. /************************************************************************/
  2. /*    Purpose..:Window Definition Procedure Skeleton                        */
  3. /************************************************************************/
  4.  
  5. #include <Types.h>
  6. #include "A4Stuff.h"    //    also included in <MacHeaders>
  7. #include "SetupA4.h"    //    required to handle callback functions
  8. #include <Controls.h>
  9. #include <Windows.h>
  10.  
  11. static short scrollval;
  12.  
  13. /****************************************************************/
  14. /* Purpose..: Scrollbars action proc                            */
  15. /* Input....: see below                                         */
  16. /* Returns..: ---                                                */
  17. /****************************************************************/
  18. static pascal void actionProc(ControlHandle ch, short part)
  19. {
  20. //
  21. //    here A4 may no longer point to our data segment
  22. //
  23.     long oldA4=SetUpA4();    //    set A4 to point to "remembered" global data segment
  24.                             //    pointer before(!) using any global data or strings
  25. //
  26. //    now we can use global data as long as we stay within this code resource
  27. //
  28.  
  29.     switch (part)
  30.     {
  31.     case inUpButton:    SetCtlValue(ch, GetCtlValue(ch) - scrollval); break;
  32.     case inDownButton:    SetCtlValue(ch, GetCtlValue(ch) + scrollval); break;
  33.     case inPageUp:        SetCtlValue(ch, GetCtlValue(ch) - 100); break;
  34.     case inPageDown:    SetCtlValue(ch, GetCtlValue(ch) + 100); break;
  35.     }
  36.  
  37.     RestoreA4(oldA4);    //    restore A4 to saved value before returning
  38. }
  39.  
  40. static short use_callback(ControlHandle theControl,Point pt)
  41. {
  42. //
  43. //    this function shows how to use callback functions within a code resources:
  44. //
  45.     RememberA4();        //    before using any callback function we have to remember
  46.                         //    our current A4 data segment pointer. Note: RememberA4 only
  47.                         //    works for the current source file (see <SetupA4.h>)
  48.     scrollval=10;
  49.  
  50.     return TrackControl(theControl,pt,actionProc);
  51. }
  52.  
  53. /************************************************************************/
  54. /*    Purpose..:  Window Definition Procedure Entry                        */
  55. /*                Important: main() must always be in the first segment    */
  56. /*    Input....:    variation code                                            */
  57. /*    Input....:    pointer to window structure                                */
  58. /*    Input....:    dispatch message                                        */
  59. /*    Input....:    a universal parameter                                    */
  60. /*    Return...:    Depends on message                                        */
  61. /************************************************************************/
  62. pascal long main(short varCode,WindowPeek theWindow,short theMessage,long param)
  63. {
  64. //
  65. //    here A4 does not point to our data segment, so we cannot use any global data.
  66. //
  67.     long    oldA4;                //    used to store old A4 value
  68.     long    ret=0;
  69.  
  70.     oldA4=SetCurrentA4();        //    setup A4 to point to global data segment
  71.                                 //    before(!) using any global data or strings
  72. //
  73. //    now we can use global data as long as we stay within this code resource
  74. //
  75.     switch(theMessage)
  76.     {
  77.     case wNew:
  78.         break;
  79.     case wDispose:
  80.         break;
  81.     case wDraw:
  82.         break;
  83.     case wHit:
  84.         break;
  85.     case wCalcRgns:
  86.         break;
  87.     case wGrow:
  88.         break;
  89.     case wDrawGIcon:
  90.         break;
  91.     }
  92.  
  93.     SetA4(oldA4);                //    restore A4 to saved value before returning
  94.     return(ret);
  95. }
  96.